package com.njwb.controller;

import com.njwb.common.pojo.User;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {
    private static Map<Integer, User> users = new HashMap<Integer,User>();
    static {
        User user1 = new User();
        user1.setId(1);
        user1.setUsername("James");
        user1.setPassword("1234");
        User user2 = new User();
        user2.setId(2);
        user2.setUsername("King");
        user2.setPassword("4321");
        users.put(user1.getId(),user1);
        users.put(user2.getId(),user2);
    }
    @GetMapping("user/{id}")
    public User getById(@PathVariable("id") Integer id){
        return users.get(id);
    }

    @GetMapping("/testFilter")
    public String testFilter(@RequestHeader("X-Request-red")String requestHeader, @RequestParam("color") String color){
        System.out.println("requestHeader->" + requestHeader);
        System.out.println("color->" + color);
        return "success";
    }

}
